export default class Compost {
  private capacity: number = 40
  private currentBag_: number = 12;


  get currentBag() {return this.currentBag_; }

  collectCompost(bags: number) {
    this.currentBag_ += bags;
    console.log(`当前肥料:${this.currentBag}`)
  }

  get canUse() {return this.currentBag_ >= 3;}

  use() {
    this.currentBag_ -= 3;
  }

  // 单例模式
  private constructor() {
  }

  private static instance: Compost | null = null;

  public static getInstance(): Compost {
    if (this.instance === null) {
      this.instance = new Compost();
    }
    return this.instance
  }
}